home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / DYN401.ZIP / examples / exam31 / main.c < prev    next >
C/C++ Source or Header  |  1995-09-27  |  2KB  |  105 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. /*
  7.  *
  8.  *    This source code is CONFIDENTIAL and
  9.  *    PROPRIETARY to Algorithms Corporation. Unauthorized
  10.  *    distribution, adaptation or use    may
  11.  *    be subject to civil and    criminal penalties.
  12.  *
  13.  *    Copyright (c) 1993 Algorithms Corporation
  14.  *    3020 Liberty Hills Drive
  15.  *    Franklin, TN  37064
  16.  *
  17.  *    ALL RIGHTS RESERVED.
  18.  *
  19.  *
  20.  *
  21.  */
  22.  
  23.  
  24.  
  25. #include "generics.h"
  26.  
  27.  
  28. static    object    (*old_gPrint)(object, object);
  29.  
  30.  
  31. static  object    new_gPrint(object self, object stream)
  32. {
  33.     printf("\n\nxxx\n");
  34.     old_gPrint(self, stream);
  35.     printf("xxxx\n\n");
  36. }
  37.  
  38. main(int argc, char *argv[])
  39. {
  40.     object    myObj;
  41.  
  42.  
  43.     InitDynace(&argc);
  44.  
  45.  
  46.     /*  Create an instance of the ShortInteger class */
  47.  
  48.     myObj = gNewWithInt(ShortInteger,  6);
  49.  
  50.     /*  print it out using the normal gPrint generic  */
  51.  
  52.     gPrint(myObj, stdoutStream);
  53.  
  54.     /*  save the old generic function in the variable old_gPrint  */
  55.  
  56.     old_gPrint = gPrint;
  57.  
  58.     /*  make gPrint execute new_gPrint  */
  59.  
  60.     gPrint = new_gPrint;
  61.  
  62.     /*  execute the new gPrint generic  */
  63.     
  64.     gPrint(myObj, stdoutStream);
  65.  
  66.  
  67.     /*  return gPrint to its original generic  */
  68.  
  69.     gPrint = old_gPrint;
  70.  
  71.     /*  try it out  */
  72.  
  73.     gPrint(myObj, stdoutStream);
  74.  
  75.     gDispose(myObj);
  76.  
  77.  
  78.     return 0;
  79. }
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87. /*
  88.  *
  89.  *    This source code is CONFIDENTIAL and
  90.  *    PROPRIETARY to Algorithms Corporation. Unauthorized
  91.  *    distribution, adaptation or use    may
  92.  *    be subject to civil and    criminal penalties.
  93.  *
  94.  *    Copyright (c) 1993 Algorithms Corporation
  95.  *    3020 Liberty Hills Drive
  96.  *    Franklin, TN  37064
  97.  *
  98.  *    ALL RIGHTS RESERVED.
  99.  *
  100.  *
  101.  *
  102.  */
  103.  
  104.  
  105.